#!/bin/bash
# start run
if [ $# -eq 0 ]; then # [ $# -eq 0 ] || [ "$@" == "" ]
    echo usage: ./run test/test.lua test, argc1: lua path, argc2: test mode
    exit -1
fi

if [ "$2" == "test" ]; then
    cp ./test/data/*.data ./data/
fi

curPath=$(pwd)

debugLib="$curPath/deps/debug/lib/?.so" # emmy_core.so EmmyLua调试插件

opensslLib="$curPath/deps/lua-openssl/?.so" # openssl.so

luvLib="$curPath/deps/luvi/deps/luv/?.so"

logLib="$curPath/deps/lualogging/src/?.lua;" # log 

CPATH="${debugLib};${opensslLib};${luvLib};"

PPATH="${logLib};"

sudo LUA_PATH="${PPATH}" LUA_CPATH="$CPATH;$LUA_CPATH" ./deps/luvit-x86_64 $1
